package at.fhooe.engine.graphics;

import java.awt.Graphics2D;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.event.KeyListener;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;


public class RenderSystem {
	
	private Screen m_screen;
	
	public void open(int width, int height, boolean fullscreen) {		
		GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
		GraphicsDevice device = env.getDefaultScreenDevice();

		if(fullscreen  && device.isFullScreenSupported()) {
			m_screen = new FullScreen();
		}
		else {
			m_screen = new WindowScreen();
		}
		m_screen.open(width, height);
	}
	
	public void addKeyListener(KeyListener keyListener) {
		m_screen.addKeyListener(keyListener);
	}
	
	public void addMouseListener(MouseListener mouseListener) {
		m_screen.addMouseListener(mouseListener);
	}
	
	public void addMouseMotionListener(MouseMotionListener mouseMotionListener) {
		m_screen.addMouseMotionListener(mouseMotionListener);
	}

	public void close() {
		m_screen.close();
	}
	
	public Graphics2D beginUpdate() {
		return m_screen.beginUpdate();
	}
	
	public void endUpdate() {
		m_screen.endUpdate();
	}
}
